<?php
/**
 * Created by PhpStorm.
 * User: woody
 * Date: 17-2-16
 * Time: 下午10:46
 */

namespace App\Http\Controllers\Api;

use App\Models\Examplesapi;
use Illuminate\Http\Request;

class ExamplesController extends ApiController {

    public function __construct()
    {
        parent::__construct();
        $this->_response['_active']['_model']       = 'examples';
        $this->_response['_active']['_action']      = '';
        $this->_response['_title']                  = '小一农货-装修案例管理';
    }


    //所有装修案例
    public function index(){
        $this->_response['_active']['_action']      = 'list';

        $examplesModel = new Examplesapi();

        $data = $examplesModel->getData();
        if(!empty($data)){
            $this->_response['examples'] = $data;
            return response()->json(['code' => 0, 'msg' => '返回成功','data'=>$this->_response]);
        }else{
            return response()->json(['code' => -1, 'msg' => '返回失败']);
        }
    }

    //具体装修案例 传入： id 返回
    public function getdata($id){

        $examplesModel = new Examplesapi();
        $data= $examplesModel->getDatalist($id);
        $this->_response['examples'] = $data;
        if(!empty($data)){
            return response()->json(['code' => 0, 'msg' => '返回成功','data'=>$this->_response['examples']]);

        }else{
            return response()->json(['code' => -1, 'msg' => '返回失败']);
        }
    }



}